﻿using IcsSEMCtrl.Service.Alarm;
using SEComEnabler.SEComStructure;

namespace TKT.Lifter.CIM.Lifter.HSMSMsg.TransferActionMsg
{
    public class S5F1
    {
        public static SXTransaction MakeTransactionSend(EcpAlarm alarm)
        {
            SXTransaction sXTransaction = new SXTransaction();
            sXTransaction.Stream = 5;
            sXTransaction.Function = 1;
            sXTransaction.Wait = true;
            sXTransaction.MessageData = "Alarm Report Send";
            sXTransaction.WriteNode(SX.SECSFormat.L, 3, "", "", new int[0]);
            if (alarm != null)
            {
                sXTransaction.WriteNode(SX.SECSFormat.B, 0, alarm.ALCD.ToString(), "AlarmCode", new int[0]);
                sXTransaction.WriteNode(SX.SECSFormat.U4, 0, alarm.ALID.ToString(), "AlarmID", new int[0]);
                sXTransaction.WriteNode(SX.SECSFormat.A, 0, alarm.ALCS, "AlarmText", new int[0]);
            }
            else
            {
                sXTransaction.WriteNode(SX.SECSFormat.B, 0, "128", "AlarmCode", new int[0]);
                sXTransaction.WriteNode(SX.SECSFormat.U4, 0, "0", "AlarmID", new int[0]);
                sXTransaction.WriteNode(SX.SECSFormat.A, 0, "ALARM IS NOT EXIST.", "AlarmText", new int[0]);
            }
            return sXTransaction;
        }
    }
}
